'''
# -*- coding:utf-8 -*-
# @Project: DevOps_api
# @Date: 2023/3/17 - 22:23
# @Author: ysg
# @Describe: 

serializer.py
'''

from rest_framework import serializers
from charts.models import Host, Host_tags, Host_sources


class HostModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = Host
        fields = ['id', 'host_ip', 'host_name', 'host_tag', 'host_source', 'host_OS', 'host_CPU', 'host_RAM',
                  'host_disk', 'add_date', 'host_status', 'is_manage', 'host_status_name', 'is_manage_name',
                  'host_tag_name', 'host_source_name']
        extra_kwargs = {
            'host_status_name': {'read_only': True},
            'is_manage_name': {'read_only': True},

            'host_tag_name': {'read_only': True},
            'host_source_name': {'read_only': True},
            'host_tag_list': {'read_only': True},
            'host_source_list': {'read_only': True},
            'host_tag': {'write_only': True},
            'host_source': {'write_only': True},

        }


class HostTagsModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = Host_tags
        fields = ['id', 'tag']


class HostSourcesModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = Host_sources
        fields = ['id', 'source']